<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改教师信息')" />
    <th:block th:include="include :: jasny-bootstrap-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-teacher-edit" th:object="${businessTeacher}">
        <input name="teacherId" th:field="*{teacherId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">教师姓名：</label>
            <div class="col-sm-8">
                <input id="teacherName" name="teacherName" th:field="*{teacherName}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">教师照片：</label>
            <div class="col-sm-8">
                <div class="fileinput fileinput-new" data-provides="fileinput">
                    <div class="fileinput-new thumbnail" style="width: 140px; height: 140px;">
                        <img th:src="*{teacherImg}"/>
                    </div>
                    <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"></div>
                    <div>
                            <span class="btn btn-white btn-file">
                                    <span class="fileinput-new">选择图片</span>
                                    <span class="fileinput-exists">更改</span>
                                    <input id="teacherImg" name="teacherImg" type="file">
                                </span>
                        <a href="#" class="btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">教师电话：</label>
            <div class="col-sm-8">
                <input id="teacherPhone" name="teacherPhone" th:field="*{teacherPhone}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">教师账号：</label>
            <div class="col-sm-8">
                <input id="teacherAccount" name="teacherAccount" th:field="*{teacherAccount}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">教师密码：</label>
            <div class="col-sm-8">
                <input id="teacherPwd" name="teacherPwd" th:field="*{teacherPwd}" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: jasny-bootstrap-js" />
<script th:inline="javascript">
    var prefix = ctx + "business/teacher";
    $("#form-teacher-edit").validate({
        focusCleanup: true
    });0

    function submitHandler() {
        var formData = new FormData();
        formData.append('teacherId', $("#teacherId").val());
        formData.append('teacherName', $("#teacherName").val());
        formData.append('teacherPhone', $("#teacherPhone").val());
        formData.append('teacherImgFile', $("#teacherImg")[0].files[0]);
        formData.append('teacherAccount', $("#teacherAccount").val());
        formData.append('teacherPwd', $("#teacherPwd").val());
        $.ajax({
            url: prefix + "/edit",
            type: 'post',
            cache: false,
            data: formData,
            processData: false,
            contentType: false,
            dataType: "json",
            success: function (result) {
                $.operate.successCallback(result);
            }
        });
    }
</script>
</body>
</html>